﻿#pragma once
#include <QWidget>
#include <QScopedPointer>
#include <QPointer>

namespace Ui { class ObjectHierarchy; }
class ObjectTreeView;

class ObjectHierarchy : public QWidget {
    Q_OBJECT
private:
    Ui::ObjectHierarchy *ui;
    struct ObjectHierarchyData;
    QScopedPointer<ObjectHierarchyData> d;
public:
    explicit ObjectHierarchy(QWidget *parent = nullptr);
    ~ObjectHierarchy();

public slots:
    void editObject(QPointer<QObject> object);

signals:
    void currentObjectChanged(QObject *object);

private slots:
    void onCurrentCapturedChanged(QPointer<QObject> current, const QPointer<QObject> previous);
    int searchObject(const QString &keywords, const QString &className = QString());
    void setCurrentObject(QObject *object);

private slots: 
    void on_editSearch_textChanged(const QString &text);
    void on_combox_typeFilter_currentIndexChanged(int index);

private:
    void initUI();
    void initFilterCombobox();
    void switchView(QPointer<ObjectTreeView> view);
    void updateSearchResultLabel(bool visible, int count = 0);
    void updateSearch();
};

